Local variables topic

D4 locals allow you to define local state independent of data. For instance, when rendering small multiples of time-series data, you might want the same x scale for all charts but distinct y scales to compare the relative performance of each metric. D4 locals are scoped by DOM elements: on set, the value is stored on the given element; on get, the value is retrieved from given element or the nearest ancestor that defines it.

Caution

Locals are rarely used; you may find it easier to store whatever state you need in the selection’s data.

Classes

Local Local variables
D4 locals allow you to define local state independent of data.
Local Local variables
D4 locals allow you to define local state independent of data.
Local Local variables
D4 locals allow you to define local state independent of data.